package com.tsc.springTemp.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: chentl
 * @Date: 2025/09/13/11:40
 * @Description:
 */
public class ThreadLearn extends  Thread{

    public void run() {
        System.out.println("线程启动了");
    }

    public static void addSum() throws InterruptedException {
        int sum = 0;
        AtomicInteger sum1= new AtomicInteger();
        int sum2=0;
        int sum3=0;
        Thread thread1 = new Thread(() -> {for (int i = 0; i < 100; i++) sum1.set(sum1.get() + i);});
        thread1.start();
        thread1.join();
        System.out.println("sum == "+ sum1.get());
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadLearn threadLearn = new ThreadLearn();
        threadLearn.start();

        addSum();

        // 创建线程池
        ExecutorService executorService = Executors.newFixedThreadPool(5);


    }
}
